package com.blog.wl2023.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author wule
 * @desc 文章实体类
 */
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "article")
@Data
public class Article extends BaseEntity{

	@Column(name = "title")
	private String title;

	@Column(name = "summary")
	private String summary;

	@Column(name = "content")
	private String content;

	@Column(name = "type_id")
	private String typeId;

	@Column(name = "author")
	private String author;

	@Column(name = "image_url")
	private String imageUrl;

	/**
	 * 默认0
	 */
	@Column(name = "views")
	private Integer views;

	/**
	 * 默认0 是否为推荐的文章(最多3个) 0:不是 1:是
	 */
	@Column(name = "is_top")
	private Integer isTop;

	/**
	 * 默认0
	 */
	@Column(name = "likes")
	private Integer likes;

	/**
	 * 默认0
	 */
	@Column(name = "comment_size")
	private Integer commentSize;

	/**
	 * 默认0 是否删除 0:未 1:是
	 */
	@Column(name = "is_delete")
	private Integer isDelete;


	@Column(name = "quote_link")
	private String quoteLink;

	@Column(name = "update_time")
	private Date updateTime;

	@Column(name = "create_time")
	private Date createTime;



	@PrePersist
	public void prePersist() {
		this.updateTime = new Date();
		this.createTime = new Date();
	}

	@PreUpdate
	public void preUpdate() {
		this.updateTime = new Date();
	}


	public Article(String uuid ,String content, String author, Date updateTime) {
		this.setUuid(uuid);
		this.content = content;
		this.author = author;
		this.updateTime = updateTime;
	}


	public Article(String title,String summary) {
		this.title = title;
		this.summary = summary;
	}


}
